#!/bin/bash

export LC_ALL=C

COMPARE_TYPE=$1
ORIG_FUNC_FILE=$2
PREDICT_FUNC_FILE=$3
GA_DIR=$4

GENE_ID=`head -n1 $GA_DIR/gene.faa | cut -b 2-`
GENE_FUNCTION=`cat $GA_DIR/../${ORIG_FUNC_FILE} | grep ${GENE_ID} | cut -f2 | head -n1`

echo -ne ${GENE_ID}'\t'$(basename $GA_DIR)

for E_DIR in ${GA_DIR}/e_*; do
    RES=`zcat ${E_DIR}/${PREDICT_FUNC_FILE} | cut -f2 | 9_annotation_analysis/compare_gene_functions.py "${COMPARE_TYPE}" "${GENE_FUNCTION}"`
    echo -ne '\t'$RES
done

echo -e '\t'${GENE_FUNCTION}

